#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>

void hand(int s)
{
    printf("最基本的信号处理函数:%d\n",s);
}

void handler(int s,siginfo_t* siginfo,void* cont)
{
    printf("高级信号处理函数:\n");
    printf("s:%d\n",s);
    printf("signal num:%d\n",siginfo->si_signo);
    printf("signal value:%d\n",siginfo->si_value.sival_int);
    printf("发送信号的进程ID：%d\n",siginfo->si_pid);


}

int main()
{
    struct sigaction act = {0};
    struct sigaction oldAct = {0};

    act.sa_handler=hand;
    act.sa_sigaction = handler;

    act.sa_flags = SA_SIGINFO;

    sigaction(2,&act,&oldAct);
    int n = 0;
    while (1)
    {
        sleep(1);
        printf("正常运行---%d %d\n",n++,getpid());
    }

    return 0;
}